# 学生信息管理系统 PyCharm
# models xf
# 2025.07.15 星期二 13:41
# from ___gxf_tool_code import 
# SPT2505

from tortoise.models import Model
from tortoise import fields

class Clas(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20, description="班级名称")

class Student(Model):
    id = fields.IntField(pk=True)
    sno = fields.IntField(unique=True, description="学号")
    name = fields.CharField(max_length=20, description="姓名")
    pwd = fields.CharField(max_length=20, description="密码")

    clas = fields.ForeignKeyField("models.Clas", related_name="students", description="班级")

    courses = fields.ManyToManyField("models.Course", related_name="students", description="课程表")

class Teachers(Model):
    id = fields.IntField(pk=True)
    tno = fields.IntField(unique=True, description="工号")
    name = fields.CharField(max_length=20, description="姓名")
    pwd = fields.CharField(max_length=20, description="密码")



class Course(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20, description="课程名称")
    teacher = fields.ForeignKeyField("models.Teachers", related_name="courses", description="授课教师")
